home *** CD-ROM | disk | FTP | other *** search
- Path: sydney.DIALix.oz.au!not-for-mail
- From: jussi@sydney.DIALix.oz.au (Jussi Jumppanen)
- Newsgroups: comp.lang.c++
- Subject: Re: Help Please
- Date: 31 Mar 1996 21:02:15 +1000
- Organization: DIALix Services, Sydney, Australia.
- Sender: jussi@sydney.DIALix.oz.au
- Message-ID: <4jlonn$qa6$1@sydney.DIALix.oz.au>
- References: <4ji7eo$kgm@daisy.flex.com.au>
- NNTP-Posting-Host: jussi@sydney.dialix.oz.au
-
- Tony L (cobweb@flex.com.au) wrote:
- : Hi all,
- :
- : I have this prog that I can't get to do a simple IF condition
- : properly. I just want it to say "You have voted for Paul Keating" if
- : the user enters Paul Keating. Yeah! I know, stupid idea for a
- : program :-)))
- :
- : When I enter Paul Keating or not, it says "You didn't vote for Paul
- : Keating" even if I did enter "Paul Keating"
- :
- : Could someone please help me with it....
- :
- : char first[15], last[15];
- : char first2[15], last2[15];
- :
- : lots removed.......
- :
- : printf("\nWhat is their last name please? ");
- : scanf(" %s", last2);
- : if (last2 == him)
- : { printf("you have voted for Paul Keating!"); }
- : else
- : { printf("\nYou didn't vote for Paul Keating!"); }
-
- The problem is in the line
- if (last2 == him)
-
- These are strings and can not be check for equality using this method
- You need to us the strcmp() or the stricmp() functions.
-
- /-----------------------------------------------------------------------/
- /- Jussi Jumppanen (jussi@sydney.dialix.oz.au) -/
- /-----------------------------------------------------------------------/
- /- Author of: Zeus for Windows, Win32 (Brief, WordStar Clone) Editor -/
- /- garbo.uwasa.fi :/windows/editor/zeusv200.zip -/
- /- SimTel.Coast.NET:/SimTel/nt/editor/ze32v200.zip -/
- /- SimTel.Coast.NET:/SimTel/win3/editor/zeusv200.zip -/
- /- http://www.coast.net/SimTel/SimTel/win3/editor/zeusv200.zip -/
- /-----------------------------------------------------------------------/
-
-
-